##################################################################
##
##
##  shuttimer.tcl script to interface with Synopsys PrimeTime
##
##  This code is provided for description purposes only. The contest
##  organizers cannot guarantee that the provided code is free of
##  bugs or defects. !!!! USE THIS CODE AT YOUR OWN RISK !!!!!
##
##
##  The contestants are free to use these functions as-is or make
##  modifications. If the contestants choose to use the provided
##  code, they are responsible for making sure that it works as
##  expected.
##
##  The code provided here has no real or implied warranties.
##
##
####################################################################

# Check command line
if { $argc != 0 } {
    puts "$argv0"
    puts "This program does not take any arguments"
    exit 1
}

# Perform checks on required environment variable
if { [catch {set contest_root $::env(ISPD_CONTEST_ROOT)} ] } {
    puts "Error: Please define environment variable ISPD_CONTEST_ROOT and re-run timer.tcl"
    exit 1
}

# Perform checks on required environment variable
if { [catch {set design_name $::env(ISPD_CONTEST_BENCHMARK)} ] } {
    puts "Error: Please define environment variable ISPD_CONTEST_BENCHMARK and re-run timer.tcl"
    exit 1
}

puts "-I- Timer: Trying to shutdown timer by writing file: $contest_root/$design_name/__TCMD_SHUTDOWN_"
exec touch $contest_root/$design_name/__TCMD_SHUTDOWN_
exit 0
